<?php
namespace App\Http\Controllers\Api;

use Illuminate\Http\Request;
use App\Service\Model\Notify;
use App\Service\Model\Orders;

class NotifyController extends BaseController{

    public function handle(Request $request){
        $params = $request->only([
            'appid',
            'outtrxid',
            'trxcode',
            'trxid',
            'trxamt',
            'initamt',
            'fee',
            'trxdate',
            'paytime',
            'trxstatus',
            'cusid',
            'trxreserved',
            'cusorderid',
            'acct',
            'sign'
        ]);
        logger('notify received',$request->all());
        Notify::create($params);
        /** @var Orders $order */
        $order = Orders::getOrderByNo($params['cusorderid']);
        $order->notifySuccess($params);
        
        return 'SUCCESS';
    }
}